package java8;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * stream只能用1次
 */
public class StreamTest2 {
    public static void main(String[] args) {
        List<String> s1 = Arrays.asList("1", "2", "3");
        List<String> s2 = Arrays.asList("6", "7", "8");
        Stream<String> stream = s2.stream();
        List<String> list = s1.stream().filter(v -> stream.anyMatch(o -> Integer.parseInt(o) > 6)).collect(Collectors.toList()); // stream has already been operated upon or closed
        System.out.println(list);
        System.out.println(Arrays.asList("1", "2").stream().filter(s ->"3".equals(s)).collect(Collectors.toList())); // []

    }
}
